package api

import (
	"chat/api/hander"
	"chat/api/middleware"
	"chat/consts"
	"chat/pkg"
	"github.com/gin-gonic/gin"
)

func LoadRouter(r *gin.Engine) {
	r.Use(middleware.Cors())
	api := r.Group("/api")
	{
		user := api.Group("/user")
		{
			user.POST("/login", hander.Login)
		}
		ws := api.Group("/ws")
		{
			ws.Use(pkg.JWTAuth(consts.JWT_KEY))
			ws.GET("/chat", hander.Chat)
		}
		video := api.Group("/video")
		{
			video.POST("/list", hander.List)
			video.POST("/select", hander.Select)
		}
		msg := api.Group("/msg")
		{
			msg.POST("/select", hander.SelectMsg)
			msg.POST("/add", hander.Add)
		}
	}
}
